<!-- Teacher_StudyCourseReply.html -->
<!DOCTYPE HTML>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
		<title>回复问题</title>
		<link rel="stylesheet" type="text/css" href="../../css/weui.css" />
		<link rel="stylesheet" href="../../css/mui.min.css" />
		<link rel="stylesheet" href="../../css/base.css"/>
		<style>
			body {
				background-color: rgba(100,100,100,0.6);
			}
			.setCenterDiv {
				position: absolute;
				background-color: #fff;
				margin-bottom: 10px;
				margin-left: 20px;
			}
			.jiangeDiv {
				height: 10px;
			}
			.inputTextareaDiv {
				margin-top: 10px;
			}
			#editNoteSpan {
				color: white;
				font-size: 16px;
			}
			#commitBtn {
				margin-right: 10px;
				color: #0CB800;
				visibility: hidden;
			}
			.tdImgSet img {
				width: 30px;
				height: 30px;
			}
			.dafenDiv {
				margin-top: 10px;
				width: 100%;
				clear: both;
				font-weight: lighter;
				margin-left: 60px;
			}
			#dafenSpan {
				float: left;
				display: block;
				line-height: 40px;
				font-size: 20px;
			}
			table {
				padding-left: 20px;
			}
			td {
			}
			#successA {
				/*position: relative;*/
			}
			#commentTextarea {
				height: 100px;
			}
			#alertDiv {
				display: none;
			}
			#fabiaoBtn {
				margin-top: 20px;
				width: 80%;
			}
			:focus {
				outline: 0;
			}
			* {
				-webkit-tap-highlight-color: rgba(255,255,255,0);
			}
			input, textarea {
				-webkit-appearance: none;
				border-radius: 0;
			}
			.writeReport .textare_div{
				width: 100%;
				margin-top: 15px;
				padding: 0 15px;
			}
			.button-super-div{
				padding: 20px 15px 24px 15px;
			}
			.mui-btn-block{
				margin: 0;
				padding: 0;
				width: 100%;
				height: 40px;
			}
		</style>
	</head>
	<body>
		<div class="showSelectListDiv ">
			<div class="setCenterDiv">
				<div class="writeReport " >
					<div class="bgwhite ">
						<button type="button" class="  right titlepos1" style="border:none;font-size: 23px;" onclick="closeFrame()">
							&times;
						</button>
						<p class="title titlepos">
							在此填写要回复的内容
						</p>
						<div class="textare_div">
							<textarea class="textarea_t " id="summary" placeholder="字数最多300字"></textarea>
						</div>
						<div class="button-super-div">
							<button id="sumbit_bt" type="button" class=" top_10   mui-btn  mui-btn-warning mui-btn-block  " onclick="ReplayCommment()" >
								提交
							</button>
						</div>
					</div>
				</div>
			</div>
		</div>
	</body>
	<script type="text/javascript" src="../../script/jquery.min.js"></script>
	<script type="text/javascript" src="../../script/util.js"></script>
	<script src="../../script/common.js"></script>
	<script type="text/javascript" src="../../script/databaseOperation.js"></script>
	<script type="text/javascript" src="../../script/url.js"></script>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/MD5.js"></script>
	<script type="text/javascript" src="../../script/requestTool.js"></script>
	<script type="text/javascript" src="../../script/utils.js"></script>
	<script type="text/javascript">
		var sxtdScore = 0;
		var postid = '';
		DBReady = function() {
			ChangeFrame();
			keyback();
		}
		//改变布局
		function ChangeFrame() {
			$('.showSelectListDiv').css('height', api.frameHeight);
			// var textWidth = api.frameWidth - 80;
			// $api.css($api.dom('textarea'), 'width:' + textWidth + 'px;');
			var dafenWidth = api.frameWidth - 120;
			$api.css($api.dom('.dafenDiv'), 'width:' + dafenWidth + 'px;');
			// 设置居中
			$api.css($api.dom('.setCenterDiv'), 'top: ' + (api.frameHeight - 210) / 2 + 'px;width: ' + (api.frameWidth - 40) + 'px;');
		}
		//安卓手机系统返回键事件
		function keyback() {
			api.addEventListener({
				name : 'keyback'
			}, function(ret, err) {
				api.closeFrame({
					name : 'Teacher_StudyCourseReply'
				});
			});
		}
		function deleteSpaceEnter(str){
			str = str.replace(/\s+/g, "");
			str = str.replace(/[\r\n]/g, "");
			return str;
		}
		//回复评论
		function ReplayCommment() {
			var newcontent = $('#summary').val();
			var jid = $api.getStorage('cfnetppjxid');
			if (api.pageParam.isxueba == 1) {
				jid = '419';
			}else if(api.pageParam.opentype == 'courseCenter') {//如果是课程中心课程
				jid = '0';
			}
			var str=notTen(newcontent);
			var param = {
				uid : $api.getStorage('cfnetppuid'),
				jid : jid,
				type : 2,
				comment : newcontent,
				fid : api.pageParam.id,
				pid : api.pageParam.planid,
				cid : api.pageParam.courseid,
				message:api.pageParam.user.rename+'的问题'+"\""+str+"\"",
			};
			if (newcontent == null || deleteSpaceEnter(newcontent) == "") {
				ShowToast("输入不能为空");
			} else if (newcontent.length > 300) {
				ShowToast("字数不能超过300字");
			} else {
				api.showProgress({
				    style: 'default',
				    animationType: 'fade',
				    title: '提交中...',
				    text: '',
				    modal: false
				});
				cfnetppPOST(url_replayQuestion, param, false, function(data, status) {
					hideProgress();
//					param['message']=api.pageParam.user.rename+'的问题'+"\""+questionData.comment+"\"";
                    if(api.pageParam.userType == '1'){//老师身份
					  	param['message']=api.pageParam.user.rename+'的问题';
						SendBusinessOperationsLogNotifi('答疑列表页', '018', param, param, '', data, '老师回复问答接口', '018-04')
					}else{
						param['message']=api.pageParam.user.rename+'的问题'+"\""+str+"\"";
						SendBusinessOperationsLogNotifi('答疑列表页', '018', param, param, '', data, '学生回复问答接口', '018-01')
					}
					if (status == 'success') {
						if (data.code == 200) {
							ShowToast('回复成功');
							sendNotifi();
							closeFrame();
						} else if (data.code == 111){
							api.toast({
								msg : '稍后再来回复吧，1分钟只能回复一条哦',
								duration : 2000,
								location : 'bottom'
							});
						} else {
							api.toast({
								msg : data.message,
								duration : 2000,
								location : 'bottom'
							});
						}
					} else {
						api.toast({
							msg : '网络异常',
							duration : 2000,
							location : 'bottom'
						});
					}
				});
			}
		}
				//字符串截取10位
    function notTen(b) {
		var str = b;
		if (str.length > 13) {
			b = str.substr(0, 12) + '...';
			return b
		} else {
			return b
		}
    }
		function closeFrame() {
			api.closeFrame({
				name : 'Teacher_StudyCourseReply'
			});
		}

		function sendNotifi() {
			api.sendEvent({
				name : 'RefreshRepalyQuestionNotifi'
			});
		}
	</script>
</html>
